﻿//        Another Demo from Andy L. & MissedMemo.com
// Borrow whatever code seems useful - just don't try to hold
// me responsible for any ill effects. My demos sometimes use
// licensed images which CANNOT legally be copied and reused.

using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;


namespace MissedMemo.MeatAndCheeseDisc.OrderEntry
{
    public static class LookupEmployee
    {
        public readonly static string strFileName = "Employees.xml";


        public static IEnumerable<string> GetAuthorizedNames( string strAuthorization )
        {
            XElement data = XElement.Load( strFileName );

            return
                from employee in data.Descendants( "Employee" )
                from authorization in employee.Descendants( "Authorized" )
                where (String)authorization.Value == strAuthorization
                select (String)employee.Attribute("DisplayName");
        }
    }
}
